from pylab import plot, show, legend, figure
import numpy
import glob
import sys
import os
import operator
tmp = []
def _sum_analyse(path='../data/data'):
    tmp_a = []
    tmp_g = []
    
    tmp_file = glob.glob(path + '/*.npz')

    for i in range(len(tmp_file)):
        statinfo = os.stat(tmp_file[i])
	tmp_file[i] = tmp_file[i],statinfo.st_size,statinfo.st_mtime
    tmp_file.sort(key=operator.itemgetter(2))
    
    for t in tmp_file[:len(tmp_file)-2]:
     
        t = numpy.load(t[0])
        tmp_a.append(t['a'].sum()/float(len(t['a'])))
        tmp_g.append(t['g'].sum()/float(len(t['g'])))
       
    
    

    figure(2)
    plot(t['a'],'o-')
    plot(t['g'],'o-')
    
    legend(['Air','Ground'])
    figure(3)
    plot(t['check_a'],'o-')
    figure(1)
    plot(tmp_g,'o-')
    tmp.append('ground_'+path)
    plot(tmp_a,'o-')
    tmp.append('air_'+path)
    

    
    legend(tmp)
    show()
#_sum_analyse(path='data_1')
#_sum_analyse(path='data')
#_sum_analyse(path='data_2')
#_sum_analyse(path='data_3')
#_sum_analyse(path='data_4')
#_sum_analyse(path='data_5')
#_sum_analyse(path='data_6')
#_sum_analyse(path='data_7')
#_sum_analyse(path='../data/data_8')
#_sum_analyse(path='../data/data_9')
#_sum_analyse(path='../data/data_10')
#_sum_analyse(path='../data/data_13')
#_sum_analyse(path='../data/data_14')
_sum_analyse(path='../data/data_test2')
